package com.cloud.logger.zchain.zchainserver.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * User: wcy
 * Date: 2017/10/31
 * Time: 11:15
 */
@RestController
@RequestMapping
public class KafkaCtl {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    /**
     * 子节点
     * @param message
     * @return
     */
    @GetMapping("send/{message}")
    @ApiOperation(value = "通过code获取子节点信息")
    public void findByCode(@PathVariable String message){
        try {
            kafkaTemplate.send("mykafka", "test", message);
        } catch (Exception e) {
            System.out.println("发送失败");
        }
    }


}
